package com.cloud.bssp.admin.wanda.convert;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cloud.bssp.admin.wanda.dto.EmployeeAttendanceDTO;
import com.cloud.bssp.admin.wanda.entity.EmployeeAttendanceDO;
import com.cloud.bssp.util.BeanCopierUtil;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * Description: 员工
 * Create Date: 2021-07-08T15:36:44.712
 * Modified By：<br>
 * Modified Date：<br>
 * Why & What is modified：<br>
 *
 * @author weirx
 * @version 1.0
 */
@Component
public class EmployeeAttendanceDoConvert {

    /**
     * DtoToDo
     *
     * @param employeeAttendanceDTO
     * @return
     */
    public static EmployeeAttendanceDO dtoToDo(EmployeeAttendanceDTO employeeAttendanceDTO) {
            EmployeeAttendanceDO employeeAttendanceDO = new EmployeeAttendanceDO();
        BeanCopierUtil.copy(employeeAttendanceDTO, employeeAttendanceDO);
        return employeeAttendanceDO;
    }

    /**
     * DoToDto
     *
     * @param employeeAttendanceDO
     * @return
     */
    public static EmployeeAttendanceDTO doToDto(EmployeeAttendanceDO employeeAttendanceDO) {
            EmployeeAttendanceDTO employeeAttendanceDTO = new EmployeeAttendanceDTO();
        BeanCopierUtil.copy(employeeAttendanceDO, employeeAttendanceDTO);
        return employeeAttendanceDTO;
    }

    /**
     * Page<DO> to Page<DTO>
     *
     * @param pageDO
     * @return
     */
    public static Page<EmployeeAttendanceDTO> pageConvert(Page<EmployeeAttendanceDO> pageDO) {
        List<EmployeeAttendanceDTO> list = listConvert(pageDO.getRecords());
        Page<EmployeeAttendanceDTO> page = new Page<>(pageDO.getCurrent(), pageDO.getSize(), pageDO.getTotal());
        page.setRecords(list);
        return page;
    }

    /**
     * list<DO> to list<DTO>
     *
     * @param listDO
     * @return
     */
    public static List<EmployeeAttendanceDTO> listConvert(List<EmployeeAttendanceDO> listDO) {
        List<EmployeeAttendanceDTO> list = new ArrayList<>();
            EmployeeAttendanceDTO employeeAttendanceDTO;
        for (EmployeeAttendanceDO employeeAttendanceDO : listDO) {
                employeeAttendanceDTO = new EmployeeAttendanceDTO();
            BeanCopierUtil.copy(employeeAttendanceDO, employeeAttendanceDTO);
            list.add(employeeAttendanceDTO);
        }
        return list;
    }
}